package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbStoreInDetail;
import com.ruoyi.supplier.service.ITbStoreInDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库明细Controller
 * 
 * @author ruoyi
 * @date 2021-03-06
 */
@RestController
@RequestMapping("/supplier/storeInDetail")
public class TbStoreInDetailController extends BaseController
{
    @Autowired
    private ITbStoreInDetailService tbStoreInDetailService;

    /**
     * 查询入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbStoreInDetail tbStoreInDetail)
    {
        startPage();
        List<TbStoreInDetail> list = tbStoreInDetailService.selectTbStoreInDetailList(tbStoreInDetail);
        return getDataTable(list);
    }

    /**
     * 导出入库明细列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:export')")
    @Log(title = "入库明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbStoreInDetail tbStoreInDetail)
    {
        List<TbStoreInDetail> list = tbStoreInDetailService.selectTbStoreInDetailList(tbStoreInDetail);
        ExcelUtil<TbStoreInDetail> util = new ExcelUtil<TbStoreInDetail>(TbStoreInDetail.class);
        return util.exportExcel(list, "storeInDetail");
    }

    /**
     * 获取入库明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbStoreInDetailService.selectTbStoreInDetailById(id));
    }

    /**
     * 新增入库明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:add')")
    @Log(title = "入库明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbStoreInDetail tbStoreInDetail)
    {
        return toAjax(tbStoreInDetailService.insertTbStoreInDetail(tbStoreInDetail));
    }

    /**
     * 修改入库明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:edit')")
    @Log(title = "入库明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbStoreInDetail tbStoreInDetail)
    {
        return toAjax(tbStoreInDetailService.updateTbStoreInDetail(tbStoreInDetail));
    }

    /**
     * 删除入库明细
     */
    @PreAuthorize("@ss.hasPermi('supplier:storeInDetail:remove')")
    @Log(title = "入库明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbStoreInDetailService.deleteTbStoreInDetailByIds(ids));
    }
}
